<%--
  User: Viktor
  Date: 12/4/13
--%>
<%@ page import="com.kma.ncpractice2013.dao.UserDAO" %>
<%@ page import="com.kma.ncpractice2013.model.User" %>
<%@ page import="java.util.UUID" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<%

    try {

        String token = request.getParameter("token");

        UserDAO dao = new UserDAO();

        User user = dao.getByRegistrationToken(token);
        user.setLogin((String)session.getAttribute("changeMail"));

        user.setRegistrationToken(UUID.randomUUID().toString());
        dao.update(user);
    } catch (Exception e) {
        out.print("Something went wrong. Try again.");
    }
%>

<h3>Mail change successful.</h3><br>
<a href="main_page.jsp">login</a>


</body>
</html>